Check for DOM ready to avoid errors