Added parse directory function as a separate file