diff --git a/distance_fast.c b/distance_fast.c
new file mode 100644
index 0000000..8b143e9
--- /dev/null
+++ b/distance_fast.c
@@ -0,0 +1,261 @@
+//  Copyright 2013 Google Inc. All Rights Reserved.
+//
+//  Licensed under the Apache License, Version 2.0 (the "License");
+//  you may not use this file except in compliance with the License.
+//  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#include <stdlib.h>
+#include <time.h>
+
+const long long max_size = 2000;         // max length of strings
+const long long N = 10;                  // number of closest words that will be shown
+const long long max_w = 50;              // max length of vocabulary entries
+
+#define MAX_STRING 100
+void ReadWord(char *word, FILE *fin) {
+  int a = 0, ch;
+  while (!feof(fin)) {
+    ch = fgetc(fin);
+    if (ch == 13) continue;
+    if ((ch == ' ') || (ch == '\t') || (ch == '\n')) {
+      if (a > 0) {
+        if (ch == '\n') ungetc(ch, fin);
+        break;
+      }
+      if (ch == '\n') {
+        strcpy(word, (char *)"</s>");
+        return;
+      } else continue;
+    }
+    word[a] = ch;
+    a++;
+    if (a >= MAX_STRING - 1) a--;   // Truncate too long words
+  }
+  word[a] = 0;
+}
+
+int main(int argc, char **argv) {
+  FILE *f;
+  char st1[max_size];
+  char *bestw[N];
+  char file_name[max_size], st[100][max_size];
+  float dist, len, bestd[N], bestclasses[N], vec[max_size];
+  int bestclasses_ids[N];
+  long long words, size, a, b, c, d, e, cn, bi[100];
+  float *M;
+  char *vocab;
+  char word[MAX_STRING];
+  clock_t begin;
+  if (argc < 2) {
+    printf("Usage: ./kmeans_txt <FILE>\nwhere FILE contains features\n <number_of_classes>");
+    return 0;
+  }
+  strcpy(file_name, argv[1]);
+  int classes = atoi(argv[2]);
+  f = fopen(file_name, "rb");
+  if (f == NULL) {
+    printf("Input file not found\n");
+    return -1;
+  }
+  
+  printf("reading data\n");
+  ReadWord(word, f);
+  words = atoi(word);
+  ReadWord(word, f);
+  size = atoi(word);
+  vocab = (char *)malloc((long long)words * max_w * sizeof(char));
+  for (a = 0; a < N; a++) bestw[a] = (char *)malloc(max_size * sizeof(char));
+  M = (float *)malloc((long long)words * (long long)size * sizeof(float));
+  if (M == NULL) {
+    printf("Cannot allocate memory: %lld MB    %lld  %lld\n", (long long)words * size * sizeof(float) / 1048576, words, size);
+    return -1;
+  }
+  for (b = 0; b < words; b++) {
+    a = 0;
+    while (1) {
+      vocab[b * max_w + a] = fgetc(f);
+      if (feof(f) || (vocab[b * max_w + a] == ' ')) break;
+      if ((a < max_w) && (vocab[b * max_w + a] != '\n')) a++;
+    }
+    vocab[b * max_w + a] = 0;
+    for (a = 0; a < size; a++) {
+        ReadWord(word,f); 
+        M[a + b * size] = atof(word); 
+    }
+    len = 0;
+    for (a = 0; a < size; a++) len += M[a + b * size] * M[a + b * size];
+    len = sqrt(len);
+    for (a = 0; a < size; a++) M[a + b * size] /= len;
+  }
+  fclose(f);
+  
+  //run kmeans
+  printf("running k-means with %i classes...\n",classes);
+  int clcn = classes, iter = 10, closeid;
+  int *centcn = (int *)malloc(classes * sizeof(int));
+  int *cl = (int *)calloc(words, sizeof(int));
+  float closev, x;
+  float *cent = (float *)calloc(classes * size, sizeof(float));
+  for (a = 0; a < words; a++) cl[a] = a % clcn;
+  for (a = 0; a < iter; a++) {
+    for (b = 0; b < clcn * size; b++) cent[b] = 0;
+    for (b = 0; b < clcn; b++) centcn[b] = 1;
+    for (c = 0; c < words; c++) {
+      for (d = 0; d < size; d++) cent[size * cl[c] + d] += M[c * size + d];
+      centcn[cl[c]]++;
+    }
+    for (b = 0; b < clcn; b++) {
+      closev = 0;
+      for (c = 0; c < size; c++) {
+        cent[size * b + c] /= centcn[b];
+        closev += cent[size * b + c] * cent[size * b + c];
+      }
+      closev = sqrt(closev);
+      for (c = 0; c < size; c++) cent[size * b + c] /= closev;
+    }
+    for (c = 0; c < words; c++) {
+      closev = -10;
+      closeid = 0;
+      for (d = 0; d < clcn; d++) {
+        x = 0;
+        for (b = 0; b < size; b++) x += cent[size * d + b] * M[c * size + b];
+        if (x > closev) {
+          closev = x;
+          closeid = d;
+        }
+      }
+      cl[c] = closeid;
+    }
+  }
+  
+  // build an array of words ordered by class and their offsets (index where each class starts)
+  int class_words[words];
+  int class_offsets[classes];
+  for(a = 0; a < classes; a++) class_offsets[a]=0;
+  for(a = 0; a < words; a++) class_offsets[cl[a]]++;
+  for(a = 1; a < classes; a++) class_offsets[a] += class_offsets[a-1];
+  for(a = 0; a < words; a++) class_words[--class_offsets[cl[a]]] = a;   
+  
+  //reading from input
+  while (1) {
+    for (a = 0; a < N; a++) bestd[a] = 0;
+    for (a = 0; a < N; a++) bestclasses[a] = 0;
+    for (a = 0; a < N; a++) bestw[a][0] = 0;
+    printf("Enter word or sentence (EXIT to break): ");
+    a = 0;
+    while (1) {
+      st1[a] = fgetc(stdin);
+      if ((st1[a] == '\n') || (a >= max_size - 1)) {
+        st1[a] = 0;
+        break;
+      }
+      a++;
+    }
+    if (!strcmp(st1, "EXIT")) break;
+    cn = 0;
+    b = 0;
+    c = 0;
+    while (1) {
+      st[cn][b] = st1[c];
+      b++;
+      c++;
+      st[cn][b] = 0;
+      if (st1[c] == 0) break;
+      if (st1[c] == ' ') {
+        cn++;
+        b = 0;
+        c++;
+      }
+    }
+    cn++;
+    for (a = 0; a < cn; a++) {
+      for (b = 0; b < words; b++) if (!strcmp(&vocab[b * max_w], st[a])) break;
+      if (b == words) b = -1;
+      bi[a] = b;
+      printf("\nWord: %s  Position in vocabulary: %lld\n", st[a], bi[a]);
+      if (b == -1) {
+        printf("Out of dictionary word!\n");
+        break;
+      }
+    }
+    if (b == -1) continue;
+    begin = clock();
+    
+    printf("\n                                              Word       Cosine distance\n------------------------------------------------------------------------\n");
+    
+    for (a = 0; a < size; a++) vec[a] = 0;
+    for (b = 0; b < cn; b++) {
+      if (bi[b] == -1) continue;
+      for (a = 0; a < size; a++) vec[a] += M[a + bi[b] * size];
+    }
+    
+    len = 0;
+    for (a = 0; a < size; a++) len += vec[a] * vec[a];
+    len = sqrt(len);
+    for (a = 0; a < size; a++) vec[a] /= len;
+    
+    // find top N centroids
+    for (a = 0; a < N; a++) bestclasses[a] = -1;
+    for (a = 0; a < N; a++) bestclasses_ids[a] = -1;
+    for (c = 0; c < classes; c++){
+    	dist = 0;
+    	for (a = 0; a < size; a++) dist += vec[a] * cent[a + size * c];
+        for (a = 0; a < N; a++) {
+        if (dist > bestclasses[a]) {
+          	for(d = N - 1; d > a; d--){
+          		bestclasses[d] = bestclasses[d-1];
+          		bestclasses_ids[d] = bestclasses_ids[d-1];
+          	}
+          	bestclasses[a] = dist;
+          	bestclasses_ids[a] = c;
+          	break;
+        }
+    	}
+    }
+    
+    // find top N words in the centroids
+    for (a = 0; a < N; a++) bestd[a] = -1;
+    for (a = 0; a < N; a++) bestw[a][0] = 0;
+    for (a = 0; a < N; a++){
+   		c = words;
+   		if(bestclasses_ids[a] < classes-1) c = class_offsets[bestclasses_ids[a]+1];
+   		b = class_offsets[bestclasses_ids[a]];
+   		for(; b < c; b++){
+   			dist = 0;
+            for (d = 0; d < size; d++) dist += vec[d] * M[d + class_words[b] * size];
+            for (d = 0; d < N; d++){
+            	if(dist > bestd[d]){
+            		for (e = N -1; e > d; e--){
+            			bestd[e] = bestd[e-1];
+            			strcpy(bestw[e], bestw[e-1]);
+            		}
+            		bestd[d] = dist;
+            		strcpy(bestw[d], &vocab[class_words[b] * max_w]);
+            		break;
+            	}
+            }
+   	    }
+   	}
+	for (a = 0; a < N; a++) printf("%50s\t\t%f\n", bestw[a], bestd[a]);   
+	printf("time spent = %f seconds\n", (double)(clock() - begin) / CLOCKS_PER_SEC);
+  }
+  // Save the K-means classes
+
+  free(centcn);
+  free(cent);
+  free(cl);
+  
+  //start running distance
+  return 0;
+}
