Trying to solve the event handler creation bug