created functions for sending and receiving data