refactored not-found handling for testability