refactor commands method