Refactored command parser