refactored according to jshint and jslint
fix syntax error