refactor the data/flow. not finished yet.