refactored for JSHint