plugin refactor