optimize code a bit to make analyze_unsolvable faster