diff --git a/w2v-server.pl b/w2v-server.pl
index 138decd..77065ab 100644
--- a/w2v-server.pl
+++ b/w2v-server.pl
@@ -223,95 +223,97 @@
 
 var svg;
 function drawEmbedding() {
-    $("#embed").empty();
-    var div = d3.select("#embed");
-
-    // get min and max in each column of Y
-    var Y = T.Y;
-    
-    svg = div.append("svg") // svg is global
-    .attr("width", 800)
-    .attr("height", 800);
-
-    var g = svg.selectAll(".b")
-      .data(data.words)
-      .enter().append("g")
-      .attr("class", "u");
-
-    g.append("text")
-      .attr("text-anchor", "top")
-      .attr("font-size", 12)
-      .attr("fill", function(d) {
-				if(d == data.target) {
-					return "red";
-				} else {
-					return "#333"
-				}
-			})
-      .text(function(d) { return d; });
-
-    var zoomListener = d3.behavior.zoom()
-      .scaleExtent([0.1, 10])
-      .center([0,0])
-      .on("zoom", zoomHandler);
-    zoomListener(svg);
-}
-
-var tx=0, ty=0;
-var ss=1;
-var iter_id=-1;
-
-function zoomHandler() {
-  tx = d3.event.translate[0];
-  ty = d3.event.translate[1];
-  ss = d3.event.scale;
-  updateEmbedding();
-}
-
-var stepnum = 0;
-
-function stopStep() {
-  clearInterval(iter_id);
-}
-
-function step() {
-  var i = T.iter;
-  if(i >= 1000) {
-   stopStep();
-  } else {
-    var cost = T.step(); // do a few steps
-    $("#cost").html("iteration " + i + ", cost: " + cost);
-    updateEmbedding();
-  }
-}
-
-	function showMap(j) {
-		data=j;
-    T.iter=0;
-    T.initDataRaw(data.vecs); // init embedding
-    drawEmbedding(); // draw initial embedding
-
-			if(iter_id >= 0) {
-				clearInterval(iter_id);
+   $("#embed").empty();
+   var div = d3.select("#embed");
+	 
+   // get min and max in each column of Y
+   var Y = T.Y;
+   
+   svg = div.append("svg") // svg is global
+						.attr("width", 800)
+						.attr("height", 800);
+	 
+   var g = svg.selectAll(".b")
+							.data(data.words)
+							.enter().append("g")
+							.attr("class", "u");
+	 
+   g.append("a")
+		.attr("xlink:href", function(word) {return "/?word="+word;})
+		.append("text")
+    .attr("text-anchor", "top")
+    .attr("font-size", 12)
+    .attr("fill", function(d) {
+			if(d == data.target) {
+				return "red";
+			} else {
+				return "#333"
 			}
-    //T.debugGrad();
-    iter_id = setInterval(step, 1);
-    //step();
-	}
-
-$(window).xxload(function() {
-  $.getJSON( "http://klinux10/word2vec/dings.json", function( j ) {
-    data = j;
-    T.initDataRaw(data.vecs); // init embedding
-    drawEmbedding(); // draw initial embedding
-
-    // T.debugGrad();
-    iter_id = setInterval(step, 1);
-    // step();
-
-  });
-});
-
+		})
+    .text(function(d) { return d; });
+	 
+   var zoomListener = d3.behavior.zoom()
+												.scaleExtent([0.1, 10])
+												.center([0,0])
+												.on("zoom", zoomHandler);
+   zoomListener(svg);
+ }
+ 
+ var tx=0, ty=0;
+ var ss=1;
+ var iter_id=-1;
+ 
+ function zoomHandler() {
+   tx = d3.event.translate[0];
+   ty = d3.event.translate[1];
+   ss = d3.event.scale;
+   updateEmbedding();
+ }
+ 
+ var stepnum = 0;
+ 
+ function stopStep() {
+   clearInterval(iter_id);
+ }
+ 
+ function step() {
+   var i = T.iter;
+   if(i >= 1000) {
+		 stopStep();
+   } else {
+     var cost = T.step(); // do a few steps
+     $("#cost").html("iteration " + i + ", cost: " + cost);
+     updateEmbedding();
+   }
+ }
+ 
+ function showMap(j) {
+	 data=j;
+   T.iter=0;
+   T.initDataRaw(data.vecs); // init embedding
+   drawEmbedding(); // draw initial embedding
+	 
+	 if(iter_id >= 0) {
+		 clearInterval(iter_id);
+	 }
+   //T.debugGrad();
+   iter_id = setInterval(step, 1);
+   //step();
+ }
+ 
+ $(window).xxload(function() {
+   $.getJSON( "http://klinux10/word2vec/dings.json", function( j ) {
+     data = j;
+     T.initDataRaw(data.vecs); // init embedding
+     drawEmbedding(); // draw initial embedding
+		 
+     // T.debugGrad();
+     iter_id = setInterval(step, 1);
+     // step();
+		 
+   });
+ });
+ 
 </script>
 </head>
 <body>
