Fixed potential null pointer error