refactor for plugin system