reducing n+1 queries