optimize path utils to make it more better