refactoring to save new pictures in database