modified: recv and send function