Added a loop in a separate thread that detects whether dots is open or not.