refactor for testability
refactor for testability
support daily and hourly frequency