rewrote as8 to use sets