refactored ingest