prevent error when document is empty