optimize ranking algorithm