commented/simplified the js code