working for dates
refactoring