Optimized switch statement; removed some XXX