Di's bug fix on rank