document request algorithm