Fixed possible nullreferenceexception