added lots of comments in javascript