fixing some N+1 queries