Problem 3 first attempt