All fixed!

I rewrote the generate method.