First working version in python