I think this function could be useful on its own, so I intentionally made it public.