somewhat decent backtracking