rate algorithm