modified backtracking