implemented funnel algorithm