now handles 404 errors properly