Refactoring input stuff