optimize the logic of filtering repo;