Rewrited for new plugin API