improved method of extracting resource id