refactor HTML and javascript