The function has been refactorized to simplify dealing with more than 2 cards. It includes test for 3 and 5 cards