made the Sort by popularity more robust