Replaced all lists with sets to get rid of duplicates and improve
performance