Reworked generation code
Condensed block code