Added helper method to backtracking.