refactor html and js