First working algo
First working algo