iterative bin search