refactored saving of source