Remove duplication in id fetching