Unsuccessful attempt at fixing problem 5. Returns incorrect answer.