fix wrong loops for empty dates