Added nil check

nil check here should be unnecessary, but for some reason it isn't.