fixed bug with rank