First working version
Better functionality