added code to handle 3 cards