Improved handling of 404 error