Fixing potencial null pointer bug.