replaced if else with table lookup