Fixed stylistic errors in the javascript file and added comments to make it easier to understand