Extract commands related logic to common