added generateAndDraw method