levelgen functionality