newer implementation of hand_rank