Fix invalid command check