first solution to assignment 2 . . . it may not be correct.