Refactoring cards.c