factor out app code dupe