refactored formatCardNumber to support paste