Updated force-checking. Algorithm should be portable to C++