Consolidate some logic