Optimized if some if-else statements