First working implementation