change port; refine some code