Fixed binary search algorithm. m is now updated correct each time in the loop.