Refactored to eliminate null pointer