extract common code, update comment