Would it be possible to put the model creation in a local function to prevent duplication?