add the basic algorithm