Translated function to plugin, now it doesn't work