getDocument function