added check for nil resource id in ref_id uniqueness check