A method for creating an anastomosis between a stomach and a portion of a small intestine, and simultaneously controlling passage of stomach contents through a pylorus with a pylorus plug that includes a valve operative to either close or at least partially open passageway through the pylorus.