refactored js in html