updated binary writing