Refactor input code