added error logging ability