added schedule stop flag and funstion/file