this function looks like copy pasta from before, maybe export it from somewhere and use it once.