apply optimkze on each row