Completed working version of the plugin