simplified resizePath() function a bit.