added error messages for debugging