finished

but this algorithm is wrongly implemented