rewrote screenshot logic