Dylan's solution to problem 2