Solution to #4-6