Input parsing refactoring