Added optimized code