bug fix and backtrack