correctly determine file type