code refactoring for module execute_targets
code refactoring