consolidate some code