implemented backtracking for local variant