Fix n+1 query