Fixed a buggy binary search implementation