fixed JS errors to please jshint