Refactored to get jslint to pass