error in rank function