final code for plugin