extraxted file traversion into seperate function