Avoid NaN

Added empty check to avoid NaN. It happened when no data is coming yet, but flush occured. See the test