Solution to #4-9