new version of the algorithm

update to v.2

not tested though! please check for errors