optimize classify and cluster