refactor date functions