Refactoring input reading