Updated Script for Data Formatting