added ranking algorithm