fixed bug when no document is selected