Added more logic to problem 32 solve