added error processing