attempted bugfix for binary search function