fixed bugs caught by jshint