added handling of 404 errors