fixing bug with click on the document