fixed error in takeScreenshot