speeding up slow querry: lazy loading and removing subquery