my code outputs the correct condition