fix undefined local variable or method `cmd'