- refactor plugin logic