optimizing S1, reducing iteration times
apply the optimization tech from S2
an attempt for improving S1
modifying the last optimization for larger k