Refactored code, vectorized dates.