refactor the source code, use fragment