added close, removed loop in thread temporarily