optimized code, optimized if else