added error check