refactoring & bug fixed advanced tool.