added ranking code among other things