added support for null dates and did some code review
code simplification