fixed read before write