Fixed a bug where backtracking didn't work correctly