add bit reading and writing