optimize the code, add the card type identification