refactored 404 handling by adding handler factory