add patch function