Consolidate duplicated code.