Minimal implementation for patching function