Retrieve correct substring