Modify if statement to capture the correct condition