updated card gen function