Preparing the event handling part