DRY out duplicate code