improved card initialization code