fixed IndexOutOfBoundsException bug
parallel to master