Added NULL termination to receive function