better handling the events