Tested and updated python script