Fix history substring search