Maybe move this function closer to where it's used.