closed existig stream and added the sleep of 1000 ms