Algorithm is implemented. Something is missing because it doesnt work