added writeToClipboard internal function
added comments