fix wrong usage of case by using an if statement to compare the error message