Refactor some code on Rule repository for category