Functions for controlling program run