Fixed null-checking error in binarySearch function.