kaikan algorithm