reorganized view code