logic of backtracking 5115428