some code consolidation