Extract common command behavior