logic for layout choice