Refactored 404 implementation