Fixed backtracking. It now works properly, but finding solutions takes forever. Have to fail faster when there is no solution