fixed serial write bug