Refactor cmd scripts