update python logic