Updated code format and added js comments.