factoring out screenshot method