fix handling of received data