Solution to #3-5