fixed local rank calculation