Rewrite some code related to IO

rewrite some code related to IO and data model.
Define some function and attribute in data model class.