consolidate logic