fixing nil errors