refactor the tool click code to be a tiny bit saner.