moved the code of filtred chunk function

moved the code of filtred chunk function next to the original one.
i'm not working on a single [pagenum] but i process all the pages and check the value of [category] to filter the content.