implement AddPattern correctly