Code optimized version