fix erroneous detection of data end