added error message handling