Refactored the way cards are being created and the selected state