added check for window.plugin