Refactoring to save new pictuers in database