refactor some var names and function externalization
selectAll feature added