function for splitting dataset