added ranking algorthm