implement function generator and add two methods