fixing nil value problem