clean up
found whether vectorized or not, the case running later is faster; switch(mode) case(v or nv) to run separatedly