diff --git a/dev/js/src/vc/statistic.js b/dev/js/src/vc/statistic.js
index 5407e8f..95710db 100644
--- a/dev/js/src/vc/statistic.js
+++ b/dev/js/src/vc/statistic.js
@@ -5,161 +5,60 @@
  * @author Helge Stallkamp
  * 
  */
- 
 
-define(['util'], function (){
+define([ 'util' ], function() {
 
-	return{
-		
-		/**
-		 * Create new statistic object
-		 */
-		create: function(statistic){
-			return Object.create(this)._init(statistic);
-		},
-	
-		/**
-		 * Initialize statistic object
-		 */
-		_init: function(statistic){
-			if(statistic === undefined){
-				throw new Error("Missing parameter");
-			}
-			else{
-			this._statistic = statistic;
-			this._visibleStat = false;
-			return this;
-			}
-		},
-		
-		/**
-		 * Display statistic object
-		 * as HTML Description List Element
-		 */
-		element : function(){
-		
-			//if this._element already exists return without doing something
-			if (this._element !== undefined) {
-	      return this._element;
-      };
-   
-      //create HTML Description List Element	
+  return {
+
+    /**
+     * Create new statistic object
+     */
+    create : function(statistic) {
+      return Object.create(this)._init(statistic);
+    },
+
+    /**
+     * Initialize statistic object
+     */
+    _init : function(statistic) {
+      if (statistic === undefined) {
+        throw new Error("Missing parameter");
+      } else {
+        this._statistic = statistic;
+        return this;
+      }
+    },
+
+    /**
+     * Display statistic object as HTML Description List Element
+     */
+    element : function() {
+
+      // if this._element already exists return without doing something
+      if (this._element !== undefined) {
+        return this._element;
+      }
+      ;
+
+      // create HTML Description List Element
       var statDL = document.createElement('dl');
-		  var statistic = this._statistic;
-			
-			var keys = Object.keys(statistic);
-			for(i = 0; i <  keys.length; i++){
-				statSp = statDL.addE('div')
-				statDT = statSp.addE('dt');
-				var k = keys[i];
-				statDT.addT(k);
-				statDT.setAttribute('title' , k);			
-				statDD = statSp.addE('dd');
-				statDD.addT(statistic[k]);
-			} 	
-			
-			this._element = statDL;
-			return this._element;
-		},
-		
-		
-		/**
-		 * 
-		 * Receive Corpus statistic from the server
-		 */			
-		getStatistic : function(vc, cb){
-			//cq = corpusQuery
-			
-			//console.log("HK ld-Type corpus = " +  vc.getLdType());
-			
-			var cq;
-			
-			cq = encodeURI(vc.toQuery());
-			
-			try{	
-				KorAP.API.getCorpStat(cq, function(statResponse){
-					if(statResponse === null){
-						cb(null);
-						return;
-					}
-					if(statResponse === undefined){
-						cb(null);
-						return;
-					}
-					
-					//catches notifications
-					if(statResponse["notifications"] !== null && statResponse["notifications"] !== undefined ){
-						notif = statResponse["notifications"];
-						KorAP.log(0, notif[0][1]);
-						cb(null);
-						return;
-					}
-					
-					cb(statResponse);
-				});
-			}
-			
-			catch(e){
-				KorAP.log(0, e);
-				cb(null);
-			}
-			
-		},
-		
-		
-		/**
-		* Shows corpus statistic
-		*/
-		showCorpStat : function(appendEl, vc){
-			
-			/*
-			* If corpus statistic is already visible, 
-			* there is no need to show the statistic again.
-			*/
-			if(this._visibleStat)
-				return;
-			
-			var statTable = document.createElement('div');									
-			statTable.classList.add('stattable', 'loading');
-			appendEl.appendChild(statTable);
-			
-			var that = this;
-			
-			
-			/*
-			* Get corpus statistic, remove "loading"-image and 
-			* append result to statTable 
-			*/
-			this.getStatistic(vc, function (statistic) {
+      var statistic = this._statistic;
 
-			statTable.classList.remove('loading');
-			statisticobj = that.create(statistic);
-			
-			if (statistic === null)
-				return; 
-			
-			statTable.appendChild(statisticobj.element());
-			
-			// Add Close Button
-			var actions = document.createElement('ul');
-			actions.classList.add('action', 'image');
-			var b = actions.addE('li');
-			b.className = 'close'; 
-			b.addE('span').addT('close');
-			statTable.appendChild(actions);
-			b.addEventListener('click', function (e){
-				statTable.parentNode.removeChild(statTable);
-				that._visibleStat = false;
-				e.halt();
-				});
-			});
-			
-			//corpus statistic is displayed
-			this._visibleStat = true;
-			// Do not load any longer
-			statTable.classList.remove('loading');
-		},	
-		
-	}
-	
+      var keys = Object.keys(statistic);
+      for (i = 0; i < keys.length; i++) {
+        statSp = statDL.addE('div')
+        statDT = statSp.addE('dt');
+        var k = keys[i];
+        statDT.addT(k);
+        statDT.setAttribute('title', k);
+        statDD = statSp.addE('dd');
+        statDD.addT(statistic[k]);
+      }
+
+      this._element = statDL;
+      return this._element;
+    },
+
+  }
+
 });
diff --git a/dev/js/src/view/corpstatv.js b/dev/js/src/view/corpstatv.js
new file mode 100644
index 0000000..457f5bf
--- /dev/null
+++ b/dev/js/src/view/corpstatv.js
@@ -0,0 +1,113 @@
+/**
+ * View: corpus statistic view
+ * 
+ * @author Helge Stallkamp
+ */
+define([ 'view', 'vc/statistic' ], function(viewClass, statClass) {
+
+  const d = document;
+
+  return {
+    create : function(vc) {
+      return Object.create(viewClass)._init([ 'vcstatistic' ]).upgradeTo(this)
+          ._init(vc);
+    },
+
+    _init : function(vc) {
+      this.vc = vc;
+      return this;
+    },
+
+    /*
+     * Returns corpus of the view,
+     * vc is used to create the corpus query string 
+     * which is needed to receive the corpus statistic from the server 
+     * (see also getStatistic : function(cb) {...))
+     */
+    getvc : function() {
+      return this.vc;
+    },
+
+
+    /**
+     * Receive Corpus statistic from the server
+     */
+    getStatistic : function(cb) {
+      // cq = corpusQuery
+      var vc = this.vc;
+      
+       // cq = corpusQuery
+      var cq;
+
+      cq = encodeURI(vc.toQuery());
+      try {
+        KorAP.API.getCorpStat(cq, function(statResponse) {
+          if (statResponse === null) {
+            cb(null);
+            return;
+          }
+          if (statResponse === undefined) {
+            cb(null);
+            return;
+          }
+
+          // catches notifications
+          if (statResponse["notifications"] !== null
+              && statResponse["notifications"] !== undefined) {
+            notif = statResponse["notifications"];
+            KorAP.log(0, notif[0][1]);
+            cb(null);
+            return;
+          }
+
+          cb(statResponse);
+        });
+      }
+
+      catch (e) {
+        KorAP.log(0, e);
+        cb(null);
+      }
+
+    },
+
+    /** 
+     * Show corpus statistic view 
+     */
+    show : function() {
+      if (this._show)
+        return this._show;
+
+      var statTable = document.createElement('div');
+      statTable.classList.add('stattable', 'loading');
+  
+      var that = this;
+     
+      /*
+      * Get corpus statistic, remove "loading"-image and
+      * append result to statTable
+      */
+      this.getStatistic(function(statistic) {
+        statTable.classList.remove('loading');
+
+        if (statistic === null)
+          return;
+
+        statisticobj = statClass.create(statistic);
+        statTable.appendChild(statisticobj.element());
+      });
+
+      this._show = statTable;
+      return statTable;
+
+    },
+
+    /**
+     * Close the view.
+     */
+    onClose : function() {
+      this.vc = undefined;
+    },
+
+  }
+});
\ No newline at end of file
