this util method is generally useful I think we should have it in core so we don't duplicate it everywhere?