some refactoring, self written generator