Attempt to index local 'photo' (a nil value)

but if i leave the part between the if and the else blank, nothing is gonna change and i will have the error again?

Should i write it this way : 

local onComplete = function(event) -- Create local variable named photo local photo = event.target if photo == nil then return false -- do something to handle the error condition. else photo:setReferencePoint(display.TopLeftReferencePoint); -- Place photo over the body -- rest of your function code end end

Thank for your help