moved python controlling code into internal class