added error logging