Added rank logic

closed #6