Adding some functions to compute ordered route path