Simplified the code by creating new js files from code that was in html files