complete the function of generating method