private int compareHands(String hand1, String hand2)
    {
        int r1 = (int) (hand1.charAt(0)) - 48, r2 = (int) (hand2.charAt(0)) - 48;

        //compare ranks
        //if one is bigger than the other, it's done
        if (r1 > r2) {
            return 1;
        } else if (r2 > r1) {
            return 2;
        }

        //check for royal flushes
        if (r1 == 9) {
            return (r2 == 9) ? 0 : 1;
        } else if (r2 == 9) {
            return 2;
        }

        int hand_length = hand1.length() - 1;

        for (int i = 1; i <= hand_length; ++i) {
            if (Card.getRank(hand1.charAt(i)) > Card.getRank(hand2.charAt(i))) {
                return 1;
            } else if (Card.getRank(hand1.charAt(i)) < Card.getRank(hand2.charAt(i))) {
                return 2;
            }
        }

        return 0;
    }