nit: maybe we can move this function closer to where it's used