refactoring html and js