 
             return 'Tie.' if (i == 5)
 
+    else if (p[1].type[0] > p[2].type[0])
+        return result.replace('%1', p[1].name)
+                     .replace('%2', type_to_s(p[1].type[0]))
+
+    else
+        return result.replace('%1', p[2].name)
+                     .replace('%2', type_to_s(p[2].type[0]))
 
 
 


    result = '%1 wins. - with %2'

    if (p[1].type[0] == p[2].type[0])
        # check if all cards have same values
        for i in [1..5]
            if (p[1].type[i] > p[2].type[i])
                return result.replace('%1', p[1].name)



    #renamining hand_types : [ 'High Card', 'Pair', 'Two Pairs', 'Three of a Kind', 'Straight',
    #'Flush', 'Full House', ]

exports.compare_hands = compare_hands
