refactored level generation