Refactors most commands in a generic one