Schegel algorithm