using sets and getting rid of regex for speed