fixing of n+1 select problem