created a function to split the data in two