// improved dispatch loop