refactoring the tool