added JS to all pages and code cleanup