updated solution to problem 15