Adding rank() function to the encoder