changed error message to use error function