Simplify handleInput().