Added event handlers.
Added user input checker