Added function to collapse pwd