Fixed bug with backtrack