restructure manage.js