error handling was throwing errors