Refactoring to save new pictures in the database