re-wrote for the new plugin API