flattens the paths