tray selection logic