remove N+1 problem in entry check using a Set lookup