Converted test4 to Generator