refactor js and html