merge get_periods and get_periods_cs (queries)