added check for valid photo object to prevent app crash