fixed bug in file counting