Assignment 6 - Improve problem 4