fix NEXT bug when length 0