swapped  inputs for the computation of r[0] (mid-rows only). Added the unique invokation counter.