replace given/whens with dispatch arrays, 15% speedup