some error checking added to the plugin