refactor out duplication