Refactoring deck logic