fix error (altho algorythm works incorrect with files)