Refactoring and added support for dates