fixed error in nil check