consolidate some code duplication