refactor input stuff