Added nil checks