created generic error handling