assignment 8 - improve problem 4