Solution to #4-8