make the tempo finding algorithm more efficient