fixed #559 : verified using jshint