Working algorithm. No training data