refactored command stuff