refactor query for get_regions