added custom error handling