rewrite TakeScreenshotRule and refactor