made it faster

used binary search.
fix
Merge pull request #1 from RedJabber/master

applied binary search