Nest event inside if statement