Use map for lookup instead of switch. Add testing.