updated reference to document within main function