ported original to plugin