Refractoring to save new pictures in database