reorganize data and funcitons