Moved get_buildings query for efficiency