Could all this be replaced by a regex with groups? Something like `(.*client[^\\.])\\..*`