fix bug in generating commands