fix leading/trailing space problem in pair input