move layout selection logic to app