Solution to problem 13 completed. Needs some cleaning up of code