added error catch handling