Extracted common command code