Reduce code duplication when retrieving sets