wrap plugin with factory function