solved problem 21 and improved solution to problem 10