Restructured the file ai.js