This new function needs some tests.