reduce nest with checking command first