Working code, except for the screen capture part