update algorithm
Merge pull request #15 from krispo/master

update alg