Move this method into a separate class and put it into the utils package.
This means that this method can be easily tested and potentially used elsewhere.