Better code for working out provider type