error handling fixes