plugin rewrite for new api