added additional error handling layer