Further refined input.js