Move the if inside the handler call