refactoring cmd plugin with fixes