Fix bug for the case when there's not enough data