added custom Error handling