Modify to check for error messages