rewrote case A and fixed grammars