Refactor javascript files and html