modified to scan multiple files