Adding pattern code