updated python code