fixing nil references