Implemented rank calculations