overhauled event handling