rewriting for forward checking. everything is now broken