move duplicated source code to one file.