Refactoring structureview.js