First working implementation. Very primitive yet