Fundamental algorithm