Added option to save model to file