Recursive bactracking