I still don't like this duplication, the logic of finding the maximum number in package policy names is the same. Maybe you could pass the regex as a parameter?    Also, package_policy service is already very long (1400+ lines) so we shouldn't be adding utility functions here.