Modify rnn rank algorithm