some refactoring of addon macro