Fix patch logic

Change-Id: I55a226e6972c63e5965434135c7fa745635b31da