Take correct substring