Replace the last line with
Although, you probably need to save the theme too... Depends on how you plan to use it next?
If that doesn't work, you might need to instance the theme too (I haven't tried this with themes specifically... Might need do preload(....).instance() or preload(....).new() .... I don't think you need to do that, but you might