fixing write calls