modified isPair function to include a check on number of cards in hand