optimized algorithm of findotherback