todo: move this into a helper