Fix receive data function