Solution to #2-5