Not working attempt at problem 51