error handling corrected