Changed to cases + Optimizations