extracted getting photos into a function