added error fuction