refactored cardhandler