Revert "code from other algoritm"

This reverts commit 71637ab419c857f0d39ad4be6dde82871726b213.