refactor date extraction