working in console, but not in extension.