Defining the error function