Added function control to python scripts