refactoring. move some logic to photo model.