added backtracking to find the actual string, not just length