Adding level generation function