Replace switch/assignments with table lookup