Fixed logic for cheking events