Refactoring plugins.js