Extract this to an helper static method.