refactored to create CardNode class