Add purely functional event handling