fix bug with ordering of commands