adds and error function