simplify the logic for cmd impl