document function