for( idx=1; idx < size; idx++) {
n++;
if (dest[idx]==lastval) continue;
//if lastval was 1, we have a 1->0 crossing
if (dest[idx-1]==1) {
for( idx=1; idx < size; idx++) {
n++;
if (dest[idx]==lastval) continue;
//if lastval was 1, we have a 1->0 crossing
if (dest[idx-1]==1) {