finishing the logic of send and receive