Refactor CommandHandler