Clean and Refactor Data Prep function