Fixed bug in input handling