fixed up code to pass jshint