fixed js to work for many different input types