refactoring towards new function generator design