Added command checking

Added command checking. Error still exists in the file cleaning.