Refactored level generator