refactored save model method