Fixed `eventHandler` function