Refactor plugins_controller.rb