Add patch function