refactored to use ETL pattern