Fixed a bug in Chainin: "Random bug" of the forum

There were missing checks against the end of the main part of the term.