refactor and cleanup html