optimized smartcard functions