check for null pointer error