further porting of basic algorithm