Refactor data ingestion