Protect against null pointer error