fixed nil check