fix n+1 queries