Refactored to save new pictures in database