Simplified code by using a tuple in combination with `endsWith`.