added handling of the 404 and 418 errors