input handler refactoring