correctly initialize splitIndex to -1