Change query to fix getting too many classes