added some null checks for date