Check that the object exists before doing anything with it