refactored the plugin mangement logic