Fixed logic. Gives the correct answer.