fix broken ranking code