refactor code for e6.html