Better solution for getting the right class.