split the JS code into 2 scripts
did some serious reafactoring on the existing code and added JSDoc
did much more refactoring and added JSDoc