Finished etl
Extracted things out into a function for better clarity