rewrote some communication code