first pass file handling