add more comments and fix jshint error