fixed nil err deref bug