change the function to geneartor