Further algorithm implementation