improve JS file structure and comments