creating session only for saving the model
small refactorings