refactoring to save new pictures in db