Changed how the function checks if the object is in the scene