refactoring for sets instead of endless if statements