correctly implement patching