Add document ready to ensure consistency