Some improvements of he algorithm, testing data is added.