refactored code according to the new generator