split cards.c into functions