Refact credit card handling code