fixed path calculation bug