correct substring end index(end index element not included in substring)