minor refactor to remove duplication. -James