figure out generator mechanism, add template to lib