refactor extension.js