refactored code to have less repeated code in the X and y dataframe generation steps