Working version of the plugin, minor changes befor feedback