Refactored so that photoId is stored in database