wrote new speed algorith, not tested