screenstot function works, but ugly code