optimized fold