fixed the handleInput function