Implemented basic event handling