some base algorithm