added ranking function