fixed bug in handling of selected/deselected documents
fixed bug