major refactoring of javascript files