refactor to split out another function