Fixed  not backtracking in edge cases