made encoding in batch buffer directly