refactoring js and html