User input code refactoring