nit: Move this into handleEvent to get better code readability.