Reimplemented the checking part algorithm. For ticket #80.