Refactor plugins.sh