Vectorized NW with optimized internal loop