input.js refactor