implemented StopChan pattern