refactor and added simple date validation