updated solution to problem 87