Modified the function: ranking