refactored using JSHint