DOM checking before doing anything