refactored tools code