Modified the function checkCard