added event handling functionality