completed calculation of ranks