Added a check that skips photos that exist in db