fix n+1 problem