Moved the JS code out to its own file