a little refactoring of plugin