refactoring and add result.txt