Tested error handler and added more logging