refactor the plugin