assignment 7 - improve problem 2