refactor to separate out the plugin code into its own component