added binary search. Still buggy