master loop now exits