some fundamental algorithm