Debugged and Fixed Calculated Rank