tried to fix that sometimes file is written multiple times