tweaked analyzeFile function