building hierarchy of classes