Refactored the input code.