extraction algorithm