fixed model building and saving