bisector used instead of naiive searching. hope for some optimization