added error catching