assignment 5 - problem 1 refine