Making sure the element exists before calling observe