Consolidate some code