added error functionality