correct sorting and filtering of logs