added a error function