optimize screenshot script