Fixed binary search issues