search based on priority but with duplication