Updated 404 logic handling