reduce size of inner loop