added capability to save model to a file