restruct app.js and other code files
small change
improve library index function