fixing memory leak in creating new contents.js