Python version of the same script