Converted from monkey patch to auxiliary function