finsh divide_files_by_periods function and some small function