implemented dynamic type and added isMain flag to model