functions for receiving and sending data