Working version of the communication code