implemented isSemanticallyValid