Fix to function which was failing tests.