bracket generation (mostly?) working