fix bug with conditional handleEvents