refactored the tool using logic