rearrange the logs in small groups