using a set instead of a list here should be a lot faster