refactor out dupe code