Refactor process command