It seems that it is quite likely that sum(randrow) != 1; maybe avoid computing it twice?