Move scene generation to separate function