Refactor JS out of html