fix algorithm
Merge pull request #16 from ryaninhust/master

fix algorithm