some refactaring in path trace