organize card looping in the templates more better