refactoring a bit, caring for vertical case, starting midpoint search
continuing midpoint search
continuing midpoint search
somehow working version. a bug to fix: why is it walking to the left??