refactor some code and add some fragments