How to write a plug-in