added read loop for plugged in mode